import { defineMock } from "./base";

export default defineMock([
  {
    url: "alarm/page",
    method: ["GET"],
    body: {
      code: "00000",
      data: {
        list: [
          {
            id: 1,
            SN: "613881224467",
            alarmType: 1,
            alarmNum: 10,
            status: 1,
            created_at: "2024-08-01 15:42:05",
          },
          {
            id: 2,
            SN: "613881198980",
            alarmType: 0,
            alarmNum: 10,
            status: 0,
            created_at: "2024-08-01 12:45:43",
          },
        ],
        total: 2,
      },
      msg: "一切ok",
    },
  },

  // 新增告警
  {
    url: "alarm",
    method: ["POST"],
    body({ body }) {
      return {
        code: "00000",
        data: null,
        msg: "新增告警成功",
      };
    },
  },

  // 获取告警表单数据
  {
    url: "alarm/:alarmId/form",
    method: ["GET"],
    body: ({ params }) => {
      return {
        code: "00000",
        data: alarmMap[params.alarmId],
        msg: "一切ok",
      };
    },
  },
  // 修改告警
  {
    url: "alarm/:alarmId",
    method: ["PUT"],
    body({ body }) {
      return {
        code: "00000",
        data: null,
        msg: "修改告警成功",
      };
    },
  },

  // 删除告警
  {
    url: "alarm/:alarmId",
    method: ["DELETE"],
    body({ params }) {
      return {
        code: "00000",
        data: null,
        msg: "删除告警" + params.id + "成功",
      };
    },
  },
]);

// 用户映射表数据
const alarmMap: Record<string, any> = {
  1: {
    id: 1,
    SN: "613881224467",
    alarmType: 1,
    alarmNum: 10,
    status: 1,
    created_at: "2024-08-01 15:42:05",
  },
  2: {
    id: 2,
    SN: "613881198980",
    alarmType: 0,
    alarmNum: 10,
    status: 0,
    created_at: "2024-08-01 12:45:43",
  },
};
